﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Webtest_view.DbFunction;

namespace Webtest_view
{
    public partial class update_user : System.Web.UI.Page
    {
        int _id;
        dbConnect _conn;
        DataSet _ds;

        protected void Page_Load(object sender, EventArgs e)
        {
             
        }

        protected void Button1_Click(object sender, EventArgs e)
        {

            String name = TextBox1.Text;
            String address = TextBox2.Text;
            String bdate = TextBox3.Text;

            try
            {
               String update_query = "update [user] set name='" + name + "',address='" + address + "',birthdate='" + bdate + "' where id='" + _id + "'";
               dbConnect _conn2 = new dbConnect();
               _conn2.insertValues(update_query);

               Label1.Text = "Update Complete";
               
            }catch(Exception ex){
                Label1.Text = ex.Message;
            }
        }

        protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            _id = Convert.ToInt32(DropDownList1.SelectedItem.Text);

      
            String select_query = "select * from [user] where id='"+_id+"'";
            try
            {
                _conn = new dbConnect();
                _ds = new DataSet();
                _ds = _conn.Select_Valeus(select_query);

            }
            catch (Exception ex)
            {
                Label1.Text = ex.Message;
            }

            TextBox1.Text = _ds.Tables[0].Rows[0][0].ToString();
            TextBox2.Text = _ds.Tables[0].Rows[0][1].ToString();
            TextBox3.Text = _ds.Tables[0].Rows[0][2].ToString();



        }
    }
}
